import { _decorator, Component, Node } from 'cc';
import { EnemyState } from './EnemyState';
const { ccclass, property } = _decorator;

@ccclass('EnemyStateMachine')
export class EnemyStateMachine {
    public currentState: EnemyState | null = null;

    public Initialize(_startState: EnemyState) {
        this.currentState = _startState;
        this.currentState.enter();
    }

    // 切换状态
    public changeState(newState: EnemyState): void {
        if (this.currentState) {
            this.currentState.exit(); // 退出当前状态
        }
        this.currentState = newState;
        this.currentState.enter();    // 进入新状态
    }
}


